{block name=location_summary}
{* Define the function *}
{function name=render_locations state=''}
	<div class="state-div">
  {foreach $items as $d}
  	{if $state eq $d.location_state}
		  <div class="col-md-12 location-centered">
		  	<hr class="blue-border">
		  	<h2 id="{$state|lower}">{$state}</h2>
		  </div>
		  {assign var='hasitems' value=1}
		  {break}
		 {/if}
  {/foreach} 
  
  {if $hasitems eq 1}
	  {foreach $items as $d}
	  	{if $state eq $d.location_state}
	       <div class="col-sm-6 col-md-4 location-summary loc" latitude="{$d.location_latitude}" longitude="{$d.location_longitude}" title="{$d.location_name}" pin="{$d.location_pin}">
					<div class="location-centered">
						<div class="new-location">{if $d.location_flag eq 1}<span>新的场馆</span>{/if}</div>
						<b class="location-suburb">{$d.location_name}</b><br />{$d.location_suburb} {$d.location_country} {$d.location_street}<br />
                        {if $d.location_longitude}
						<a href="http://api.map.baidu.com/marker?location={$d.location_longitude},{$d.location_latitude}&title={$d.location_name}&content=&output=html&src=rsgk" target="_blank">查看地图</a><br />
                        {/if}
						{if $d.location_url}<a href="{externallink data=$d.location_url}" target="_blank">{$d.location_url|replace:"https://":""|replace:"http://":""}</a><br />{/if}
					</div>
                    <div class="location-bottom">
                        <a class="enrolnow" href="/enrol/search?id={$d.location_object_id}&location={$d.location_name}">查找课程</a>
                    </div>
				</div>
			{/if}
	  {/foreach}
  {/if}  
	</div>
{/function}
    {call name=render_locations items=$locations state='北京'}
    {call name=render_locations items=$locations state='天津'}
{/block}